
<template>
<div  class="model_detail-wrapper">
  <modal_com  :modalShow="modalShow"  :is_click_see="is_click_see" :allowMultiple="true" :useSetIterval="useSetIterval" type="fullscreen" @toHidden='toHidden' @yes_event='yes_event'>
    <div slot='header'>
      {{header}}
    </div>
    <div slot='content'>
      <component v-if='inopenCtl&&components_name&&content_show' :is='components_name' :click_see_conf='click_see_conf' :ctl="ctl" :modalShow="modalShow" :detail_id="detail_id" ></component>
    </div>

    </modal_com>

</div>

</template>

<script type="text/ecmascript-6">
import modal_com from 'components/modal/modal_com'
import detailCom from 'components/detail/detailCom'
import click_see_show from 'components/detail/click_see_show'
import tool from 'src/util/tool';
import util from '_util/index';
import in_array from 'in_array';

import { createNamespacedHelpers } from 'vuex'
const {
  mapState,
  mapMutations,
} = createNamespacedHelpers('global')

export default {
  data() {
    return {
      modelConf: {},
      detail_id:null,
      click_see_conf:null,
      is_click_see:false,
      actions: {
        positive: '提交',
        negative: '取消'
      },
      vo: {}
    }
  },
  components: {
    modal_com,detailCom,click_see_show
  },
  methods: {
    up_detail_id(id) {
      this.detail_id = id;
      this.is_click_see = false;
    },
    up_click_see_conf(conf) {
      this.is_click_see = true;
      this.click_see_conf = conf;
    },
    setVal(fname,val) {
      this.vo[fname]= val;
    },
    toHidden() {
      this.$emit('modalComHidden')
    },
    yes_event() {
      this.$emit('doSearch', this.vo)
    },
    setModelConf() {
      this.getModel(1);
      let model = this.vuexRs
      this.modelConf=model;
    },
      ...mapMutations(['getModel']),
  },
  watch: {
    ctl: function (val, old) {
      if (val != old) {
        this.setModelConf()
      }
    }
  },
  props: ['modalShow'],
  created() {
    this.setModelConf();

    let eventVue = util.store.get(this,'eventVue');
    eventVue.$on('up_detail_id', this.up_detail_id)
    eventVue.$on('up_click_see_conf', this.up_click_see_conf)

  },
  computed: {
    useSetIterval() {
      if(this.is_click_see) {
        return this.click_see_conf.refresh;
      }
      return false;
    },
    content_show() {
      return this.components_name=='detailCom'?this.detail_id:true;
    },
    components_name() {
      return this.is_click_see?'click_see_show':'detailCom';
    },
    ctl() {
      return this.$route.query.ctl;
    },
    header() {
      return this.is_click_see?'查看信息':`${this.modelConf.title}——详情`;
    },
    inopenCtl() {
      return in_array(this.ctl,['Trodetail'])||this.is_click_see;
    },
    ...mapState(['vuexRs'])
  },
  mounted() {
  }
}
</script>
